package com.dao;

import java.util.List;

import org.hibernate.Criteria;
import org.hibernate.Session;
import org.hibernate.criterion.Restrictions;

import com.hibernate.HibernateSessionFactory;
import com.model.Room;


/**
 * 对房间相关表模型的增删改查
 *  
 * @author 0912652
 */

public class RoomDao {
	
	public List<Room> findRoomByType(int rtid){
		Session session = HibernateSessionFactory.getSession();
		Criteria criteria = session.createCriteria(Room.class);
		Criteria cr = criteria.createCriteria("roomtype");
		
		cr.add(Restrictions.eq("rtid", rtid));
		List<Room> rooms = criteria.list();
		
		return rooms;
	}
	
	public Room findRoomById(int rid){
		Session session = HibernateSessionFactory.getSession();
		Criteria criteria = session.createCriteria(Room.class);
		
		criteria.add(Restrictions.eq("rid", rid));
		Room room = (Room)criteria.uniqueResult();
		return room;
	}

}
